package work.dp;

/**
 * @author WDH
 * @description
 * @date 2024年12月03日 14:18
 */

public class Problem746 {
    public int minCostClimbingStairs(int[] cost) {
        int[] dp = new int[cost.length + 1];
        dp[0] = 0;
        dp[1] = cost[0];
        dp[2] = cost[1];
        for (int i = 3; i < cost.length + 1; i++) {
            dp[i] = Math.min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-1]);
        }
        int ans = Math.min(dp[cost.length ],dp[cost.length-1]);
        return ans;
    }
}
